package com.wealth.scsj.b_app.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.wealth.scsj.b_app.base.BindBankCardBase;
import com.wealth.scsj.b_app.bean.BaseBean;
import com.wealth.scsj.b_app.model.BindBankCardModel;


import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 新增和修改收货地址presenter
 */

public class BindBankCardPresenter extends BasePresenter implements BindBankCardBase.IPresenter {

    private BindBankCardBase.IModel mModel;
    private BindBankCardBase.IView mView;

    public BindBankCardPresenter(BindBankCardBase.IView view) {
        mView = view;
        mModel = new BindBankCardModel();
    }


    @Override
    public void deliverSendSmsData(RequestBody requestBody) {
        addSubscription(mModel.getSendSmsData(requestBody, new ResponseCallback<BaseBean>() {
            @Override
            public void onSuccess(BaseBean result) {
                if (result.getStatusCode() == 200) {
                    mView.SendSmsSuccessMsg("获取成功", result);
                    Logger.d("新增收货地址成功" + result.toString());
                } else {
                    mView.showDAErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showDAErrorMsg(msg);
                Log.e("onFaild", msg + "");
            }
        }));
    }

    @Override
    public void deliverBindData(RequestBody requestBody) {
        addSubscription(mModel.getBindData(requestBody, new ResponseCallback<BaseBean>() {
            @Override
            public void onSuccess(BaseBean result) {
                if (result.getStatusCode() == 200) {
                    mView.BindSuccessMsg("获取成功", result);
                    Logger.d("修改收货地址成功" + result.toString());
                } else {
                    mView.showDAErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showDAErrorMsg(msg);
                Log.e("onFaild", msg + "");
            }
        }));
    }
}
